<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:fina="http://www.fina2.net/taglibs">
      <body>
       <h:form>
        
       <a4j:include viewId="toolBar.xhtml"/>
        <table style="width:100%">
        <tr>
        <td valign="top" style="width:80%">
        <rich:datascroller for="bankTypesTable"/>
        <rich:dataTable id="bankTypesTable" rows="15" var="bt"  value="#{bankTypeSession.bankTypes}" style="width:100%">
            <rich:column sortBy="#{bt.code}" style="text-align:center">
                <f:facet name="header">
                #{messages['fina2.bank.bankCode']}
                </f:facet>
                <h:outputText value="#{bt.code}" />
            </rich:column>
            <rich:column sortBy="#{bt.description}" style="text-align:center">
                <f:facet name="header">
                #{messages['fina2.description']}
                </f:facet>
                <h:outputText value="#{bt.description}" />
            </rich:column>
            <rich:column sortIcon="/images/edit.gif" style="text-align:center;">
                <f:facet name="header">
                #{messages['fina2.amend']}
                </f:facet>
                <a4j:commandButton disabled="#{(!userSession.hasPermission('fina2.bank.amend'))&amp;&amp;(!roleSession.hasPermission(userSession.currentUser.id,'fina2.bank.amend'))}" action="#{bankTypeSession.setSelectedBankType(bt)}" oncomplete="Richfaces.showModalPanel('bankTypeEditPanel')" reRender="bankTypeEdit" image="/images/edit.gif" >
                    <a4j:actionparam name="oldCode" assignTo="#{bankTypeValidator.code}" value="#{bt.code}"/>
                </a4j:commandButton>
            </rich:column>
            <rich:column sortIcon="/images/remove.gif" style="text-align:center;">
                <f:facet name="header">
                #{messages['fina2.delete']}
                </f:facet>
               
                <a4j:commandButton disabled="#{(!userSession.hasPermission('fina2.bank.delete'))&amp;&amp;(!roleSession.hasPermission(userSession.currentUser.id,'fina2.bank.delete'))}" oncomplete="Richfaces.showModalPanel('confirmation')" image="/images/remove.gif" reRender="removeBankType">
                  <a4j:actionparam name="bankToRemove" assignTo="#{bankTypeSession.code}" value="#{bt.code}"/>
                </a4j:commandButton>
            </rich:column>
        </rich:dataTable>
        </td>
        </tr>
        </table>
       </h:form>
       
       <rich:modalPanel id="confirmation" autosized="true" resizeable="false" width="300" >
           <f:facet name="header">
               #{messages['fina2.web.confirm']}
           </f:facet>
           <f:facet name="controls">
               <h:graphicImage value="../images/close.gif"  onclick="Richfaces.hideModalPanel('confirmation')"/>
           </f:facet>
           <h:form>
               <s:div id="removeBankType">
                   <table align="center" width="100%" style="font-size:12px">
                       <tr>
                          <td style="font-size:12px">#{messages['fina2.bank.bankTypeDeleteQuestion']}</td>
                       </tr>
                   </table>
              </s:div>
              <rich:spacer height="5px"/>
              <table align="center">
                  <tr>
                      <td>
                          <a4j:commandButton action="#{bankTypeSession.removeBankType}" value="#{messages['fina2.web.ok']}" style="width:80px" oncomplete="Richfaces.hideModalPanel('confirmation')" reRender="bankTypesTable"/>
                      </td>
                      <td><rich:spacer width="3px"/></td>
                      <td><a4j:commandButton onclick="Richfaces.hideModalPanel('confirmation')" value="#{messages['fina2.web.cancel']}" style="width:80px"/></td>
                  </tr>
             </table>
        </h:form>
       </rich:modalPanel>
       
       <rich:modalPanel id="bankTypePanel" autosized="true" resizeable="false" width="470">
           <f:facet name="header">
               #{messages['fina2.bank.bankTypesAction']}
           </f:facet>
           <f:facet name="controls">
               <h:graphicImage value="/images/close.gif" onclick="Richfaces.hideModalPanel('bankTypePanel')"/>
           </f:facet>
           <h:form>
               <s:validateAll>
               <f:facet name="beforeInvalidField">
                   <s:message style="font-size:12px;color:red"/>
               </f:facet>
               <f:facet name="aroundInvalidField">
               
               </f:facet>
               <f:facet name="afterInvalidField">
                   <s:div style="display:block;padding-bottom:12px"/>
               </f:facet>
               <s:div id="bankTypes">
                   <table align="center" width="100%" style="font-size:12px">
                       <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                       </tr>
                       <tr>
                           <td>#{messages['fina2.code']}</td>
                           <td><div style="color:red">*</div></td>
                           <td>
                               <s:decorate>
                                  <h:inputText value="#{bankTypeSession.bankType.code}" validator="#{bankTypeValidator.validateCode}" required="true" requiredMessage="#{messages['fina2.bank.pleaseEnterCode']}" style="width:330px"/>
                               </s:decorate>
                           </td>
                      </tr>
                      <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                      </tr>
                      <tr>
                          <td>#{messages['fina2.description']}</td>
                          <td><div style="color:red">*</div></td>
                          <td>
                              <s:decorate> 
                                 <h:inputText value="#{bankTypeSession.bankType.description}" validator="#{bankTypeValidator.validateDescription}" required="true" requiredMessage="#{messages['fina2.pleaseEnterDescription']}"  style="width:330px"/>
                              </s:decorate>
                          </td>
                      </tr>
                </table>
                <rich:spacer height="3px"/>
                <table align="center" >
                   <tr>
                       <td><a4j:commandButton reRender="bankTypes"  action="#{bankTypeSession.addBankType()}" value="#{messages['fina2.web.ok']}" style="width:80px"/></td>
                       <td><rich:spacer width="3px"/></td>
                       <td><a4j:commandButton onclick="Richfaces.hideModalPanel('bankTypePanel');return false;" value="#{messages['fina2.cancel']}" style="width:80px"/></td>
                   </tr>
                </table>
               </s:div>
               </s:validateAll>
           </h:form>  
       </rich:modalPanel>
       
       <rich:modalPanel id="bankTypeEditPanel" resizable="false" autosized="true" width="470">
           <f:facet name="header">
                #{messages['fina2.amend']}
           </f:facet>
           <f:facet name="controls">
               <h:graphicImage value="/images/close.gif" onclick="Richfaces.hideModalPanel('bankTypeEditPanel')"/>
           </f:facet>
           <h:form>
               <s:validateAll>
                   <f:facet name="beforeInvalidField">
                       <s:message style="font-size:12px;color:red"/>
                   </f:facet>
                   <f:facet name="aroundInvalidField">
                   
                   </f:facet>
                   <f:facet name="afterInvalidField">
                       <s:div style="display:block;padding-bottom:12px"/>
                   </f:facet>
                   <s:div id="bankTypeEdit">
                       <table align="center" width="100%" style="font-size:12px">
                       <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                       </tr>
                       <tr>
                           <td>#{messages['fina2.code']}</td>
                           <td><div style="color:red">*</div></td>
                           <td>
                               <s:decorate>
                                  <h:inputText value="#{bankTypeSession.selectedBankType.code}" validator="#{bankTypeValidator.validateEditCode}" required="true" requiredMessage="#{messages['fina2.bank.pleaseEnterCode']}" style="width:330px"/>
                               </s:decorate>
                           </td>
                      </tr>
                      <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                      </tr>
                      <tr>
                          <td>#{messages['fina2.description']}</td>
                          <td><div style="color:red">*</div></td>
                          <td>
                              <s:decorate> 
                                 <h:inputText value="#{bankTypeSession.selectedDesc}" validator="#{bankTypeValidator.validateDescription}" required="true" requiredMessage="#{messages['fina2.pleaseEnterDescription']}"  style="width:330px"/>
                              </s:decorate>
                          </td>
                      </tr>
                </table>
                <rich:spacer height="3px"/>
                <table align="center" >
                   <tr>
                       <td><a4j:commandButton reRender="bankTypeEdit" data="#{bankTypeSession.success}" action="#{bankTypeSession.updateBankType()}" oncomplete="if(data)Richfaces.hideModalPanel('bankTypeEditPanel');" value="#{messages['fina2.web.ok']}" style="width:80px"/></td>
                       <td><rich:spacer width="3px"/></td>
                       <td><a4j:commandButton onclick="Richfaces.hideModalPanel('bankTypeEditPanel');return false;" value="#{messages['fina2.cancel']}"  style="width:80px"/></td>
                   </tr>
                </table>    
                </s:div>
               </s:validateAll>
           </h:form>
       </rich:modalPanel>
      </body>
</html>